home *** CD-ROM | disk | FTP | other *** search
/ Aminet 21 / Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso / Aminet / gfx / show / gs_src_gs.lha / gs5.03 / gxclpath.h < prev    next >
C/C++ Source or Header  |  1997-06-13  |  8KB  |  203 lines

  1. /* Copyright (C) 1995, 1996, 1997 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of Aladdin Ghostscript.
  4.   
  5.   Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author
  6.   or distributor accepts any responsibility for the consequences of using it,
  7.   or for whether it serves any particular purpose or works at all, unless he
  8.   or she says so in writing.  Refer to the Aladdin Ghostscript Free Public
  9.   License (the "License") for full details.
  10.   
  11.   Every copy of Aladdin Ghostscript must include a copy of the License,
  12.   normally in a plain ASCII text file named PUBLIC.  The License grants you
  13.   the right to copy, modify and redistribute Aladdin Ghostscript, but only
  14.   under certain conditions described in the License.  Among other things, the
  15.   License requires that the copyright notice and this notice be preserved on
  16.   all copies.
  17. */
  18.  
  19. /* gxclpath.h */
  20. /* Internal definitions for higher-level command list facilities. */
  21. /* Extends (requires) gxcldev.h */
  22. #include "gxfixed.h"            /* for gzpath.h */
  23.  
  24. /* Define the flags indicating whether a band knows the current values of */
  25. /* various miscellaneous parameters (pcls->known). */
  26. #define flatness_known        (1<<0)
  27. #define fill_adjust_known    (1<<1)
  28. #define ctm_known        (1<<2)
  29. #define line_width_known    (1<<3)
  30. #define miter_limit_known    (1<<4)
  31. #define misc0_known        (1<<5)
  32. #define misc1_known        (1<<6)
  33. #define dash_known        (1<<7)
  34. #define clip_path_known        (1<<8)
  35. #define stroke_all_known    ((1<<9)-1)
  36. #define color_space_known    (1<<9)
  37. /*#define all_known        ((1<<10)-1)*/
  38.  
  39. /* Define the drawing color types for distinguishing different */
  40. /* fill/stroke command variations. */
  41. typedef enum {
  42.   cmd_dc_type_pure = 0,
  43.   cmd_dc_type_ht = 1,
  44.   cmd_dc_type_color = 2
  45. } cmd_dc_type;
  46.  
  47. /* Extend the command set.  See gxcldev.h for more information. */
  48. typedef enum {
  49.     cmd_op_misc2 = 0xd0,        /* (see below) */
  50.       cmd_opv_set_flatness = 0xd0,    /* flatness(float) */
  51.       cmd_opv_set_fill_adjust = 0xd1,   /* adjust_x/y(fixed) */
  52.       cmd_opv_set_ctm = 0xd2,    /* (0=0,0, 1=V,V, 2=V,-V, 3=U,V)x */
  53.                     /* (xx+yy,yx+xy)(0=0, 1=V)x(tx,ty), */
  54.                     /* 0..5 x coeff(float) */
  55.       cmd_opv_set_line_width = 0xd3,   /* width(float) */
  56.       cmd_opv_set_misc2 = 0xd4,
  57. #define cmd_set_misc2_cap_join (0 << 6)    /* 00: cap(3)join(3) */
  58. #define cmd_set_misc2_ac_op_sa (1 << 6)    /* 01: 0(3)acc.curves(1)overprint(1) */
  59.                     /*   stroke_adj(1) */
  60. #define cmd_set_misc2_notes (2 << 6)    /* 10: seg.notes(6) */
  61. #define cmd_set_misc2_unused (3 << 6)    /* 11: -unused- */
  62.       cmd_opv_set_miter_limit = 0xd5,   /* miter limit(float) */
  63.       cmd_opv_set_dash = 0xd6,    /* adapt(1)abs.dot(1)n(6), dot */
  64.                     /* length(float), offset(float), */
  65.                     /* n x (float) */
  66.       cmd_opv_enable_clip = 0xd7,    /* (nothing) */
  67.       cmd_opv_disable_clip = 0xd8,    /* (nothing) */
  68.       cmd_opv_begin_clip = 0xd9,    /* (nothing) */
  69.       cmd_opv_end_clip = 0xda,    /* outside? */
  70.       cmd_opv_set_color_space = 0xdb,  /* base(4)Indexed?(2)0(3) */
  71.                     /* [, hival#, table|map] */
  72.       cmd_opv_begin_image = 0xdc,    /* BPCi(3)(0=mask) */
  73. #ifdef FUTURE
  74.                     /* more params(1) */
  75. #else
  76.                     /* Interpolate(1) */
  77. #endif
  78.                     /* Matrix?(1)Decode?(1) */
  79.                     /* adjust/CombineWithColor(1) */
  80.                     /* rect?(1), */
  81. #ifdef FUTURE
  82.                     /* [format(2)Interpolate(1)0(5),] */
  83. #endif
  84.                     /* width#, height#, */
  85.                     /* [, aabbcd00, 0..6 x coeff(float)] */
  86.                     /* [, (0=default, 1=swapped default, */
  87.                     /* 2=0,V, 3=U,V)x4, */
  88.                     /* 0..8 x decode(float)], */
  89.                     /* [, x0#, w-x1#, y0#, h-y1#] */
  90.       cmd_opv_image_data = 0xdd,    /* height# (premature EOD if 0), */
  91.                     /* raster#, <data> */
  92.       cmd_opv_set_color = 0xde,    /* (0000abcd | */
  93.                     /*  0001aaaa abbbbbcc cccddddd), */
  94.                     /* (3|4) x level#: colored halftone */
  95.                     /* with base colors a,b,c,d */
  96.     cmd_op_segment = 0xe0,        /* (see below) */
  97.       cmd_opv_rmoveto = 0xe0,    /* dx%, dy% */
  98.       cmd_opv_rlineto = 0xe1,    /* dx%, dy% */
  99.       cmd_opv_hlineto = 0xe2,    /* dx% */
  100.       cmd_opv_vlineto = 0xe3,    /* dy% */
  101.       cmd_opv_rrcurveto = 0xe4,    /* dx1%,dy1%, dx2%,dy2%, dx3%,dy3% */
  102.       cmd_opv_hvcurveto = 0xe5,    /* dx1%, dx2%,dy2%, dy3% */
  103.       cmd_opv_vhcurveto = 0xe6,    /* dy1%, dx2%,dy2%, dx3% */
  104.       cmd_opv_nrcurveto = 0xe7,    /* dx2%,dy2%, dx3%,dy3% */
  105.       cmd_opv_rncurveto = 0xe8,    /* dx1%,dy1%, dx2%,dy2% */
  106.       cmd_opv_rmlineto = 0xe9,    /* dx1%,dy1%, dx2%,dy2% */
  107.       cmd_opv_rm2lineto = 0xea,    /* dx1%,dy1%, dx2%,dy2%, dx3%,dy3% */
  108.       cmd_opv_rm3lineto = 0xeb,    /* dx1%,dy1%, dx2%,dy2%, dx3%,dy3%, */
  109.                     /* [-dx2,-dy2 implicit] */
  110.       cmd_opv_vqcurveto = 0xec,    /* dy1%, dx2%[,dy2=dx2 with sign */
  111.                     /* of dy1, dx3=dy1 with sign of dx2] */
  112.       cmd_opv_hqcurveto = 0xed,    /* dx1%, [dx2=dy2 with sign */
  113.                     /* of dx1,]%dy2, [dy3=dx1 with sign */
  114.                     /* of dy2] */
  115.       cmd_opv_closepath = 0xee,    /* (nothing) */
  116.     cmd_op_path = 0xf0,        /* (see below) */
  117.         /* The path drawing commands come in groups: */
  118.         /* each group consists of a base command plus an offset */
  119.         /* which is a cmd_dc_type. */
  120.       cmd_opv_fill = 0xf0,
  121.       cmd_opv_htfill = 0xf1,
  122.       cmd_opv_colorfill = 0xf2,
  123.       cmd_opv_eofill = 0xf3,
  124.       cmd_opv_hteofill = 0xf4,
  125.       cmd_opv_coloreofill = 0xf5,
  126.       cmd_opv_stroke = 0xf6,
  127.       cmd_opv_htstroke = 0xf7,
  128.       cmd_opv_colorstroke = 0xf8
  129. } gx_cmd_xop;
  130.  
  131. static const byte clist_segment_op_num_operands[] =
  132.  { 2, 2, 1, 1, 6, 4, 4, 4, 4, 4, 6, 6, 2, 2, 0
  133.  };
  134.  
  135. #define cmd_misc2_op_name_strings\
  136.   "set_flatness", "set_fill_adjust", "set_ctm", "set_line_width",\
  137.   "set_misc2", "set_miter_limit", "set_dash", "enable_clip",\
  138.   "disable_clip", "begin_clip", "end_clip", "set_color_space",\
  139.   "begin_image", "image_data", "set_color", "?df?"
  140.  
  141. #define cmd_segment_op_name_strings\
  142.   "rmoveto", "rlineto", "hlineto", "vlineto",\
  143.   "rrcurveto", "hvcurveto", "vhcurveto", "nrcurveto",\
  144.   "rncurveto", "rmlineto", "rm2lineto", "rm3lineto",\
  145.   "vqcurveto", "hqcurveto", "closepath", "?ef?"
  146.  
  147. #define cmd_path_op_name_strings\
  148.   "fill", "htfill", "colorfill", "eofill",\
  149.   "hteofill", "coloreofill", "stroke", "htstroke",\
  150.   "colorstroke", "?f9?", "?fa?", "?fb?",\
  151.   "?fc?", "?fd?", "?fe?", "?ff?"
  152.  
  153. /*
  154.  * We represent path coordinates as 'fixed' values in a variable-length,
  155.  * relative form (s/t = sign, x/y = integer, f/g = fraction):
  156.  *    00sxxxxx xfffffff ffffftyy yyyygggg gggggggg
  157.  *    01sxxxxx xxxxffff ffffffff
  158.  *    10sxxxxx xxxxxxxx xxxxffff ffffffff
  159.  *    110sxxxx xxxxxxff
  160.  *    111----- (a full-size `fixed' value)
  161.  */
  162. #define is_bits(d, n) !(((d) + ((fixed)1 << ((n) - 1))) & (-(fixed)1 << (n)))
  163.  
  164. /* ---------------- Driver procedure support ---------------- */
  165.  
  166. /* The procedures and macros defined here are used when writing */
  167. /* (gxclimag.c, gxclpath.c). */
  168.  
  169. /* Compare and update members of the imager state. */
  170. #define state_neq(member)\
  171.   cdev->imager_state.member != pis->member
  172. #define state_update(member)\
  173.   cdev->imager_state.member = pis->member
  174.  
  175. /* ------ Exported by gxclpath.c ------ */
  176.  
  177. /* Write out the color for filling, stroking, or masking. */
  178. /* Return a cmd_dc_type. */
  179. int cmd_put_drawing_color(P3(gx_device_clist_writer *cldev,
  180.                  gx_clist_state *pcls,
  181.                  const gx_drawing_color *pdcolor));
  182.  
  183. /* Clear (a) specific 'known' flag(s) for all bands. */
  184. /* We must do this whenever the value of a 'known' parameter changes. */
  185. void cmd_clear_known(P2(gx_device_clist_writer *cldev, uint known));
  186.  
  187. /* Write out values of any unknown parameters. */
  188. #define cmd_do_write_unknown(cldev, pcls, must_know)\
  189.   if ( ~(pcls)->known & (must_know) )\
  190.     { int code = cmd_write_unknown(cldev, pcls, must_know);\
  191.       if ( code < 0 ) return code;\
  192.     }
  193. int cmd_write_unknown(P3(gx_device_clist_writer *cldev, gx_clist_state *pcls,
  194.              uint must_know));
  195.  
  196. /* Check whether we need to change the clipping path in the device. */
  197. bool cmd_check_clip_path(P2(gx_device_clist_writer *cldev,
  198.                 const gx_clip_path *pcpath));
  199.  
  200. /* Construct the parameters for writing out a matrix. */
  201. /* We need a buffer of at least 1 + 6 * sizeof(float) bytes. */
  202. byte *cmd_for_matrix(P2(byte *cbuf, const gs_matrix *pmat));
  203.